#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int mmax = 0, res = 0;
    void dfs(vector<int>& nums, int index, int sum)
    {
        if (sum > mmax)
        {
            mmax = sum;
            res = 1;
        }
        else if (sum == mmax)
            ++res;
        for (int i = index; i < nums.size(); i++)
        {
            dfs(nums, i + 1, sum | nums[i]);
        }
    }
    int countMaxOrSubsets(vector<int>& nums) {
        dfs(nums, 0, 0);
        return res;
    }
};